package com.angel.activity;

import java.util.ArrayList;

import com.angel.adapter.MyPagerAdapter;
import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ShowPicActivity extends Activity {
	/** 显示活动图片的窗口 */
	private ViewPager viewPager;
	private TextView topText;
	private Intent intent;
	private ArrayList<String> urlList;
	private LayoutInflater inflater;
	private ArrayList<View> viewGroupList;
	private ViewGroup viewGroup;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pic_activity);
		 MobclickAgent.onError(this);//自动捕获异常退出（FC ）
		/*获取传递过来的Intent大图片*/
		intent=getIntent();
		urlList=intent.getStringArrayListExtra("bigImgUrls");
//		Log.i("ShowPicActivity","ShowPicActivity"+ urlList.get(1));
		inflater=getLayoutInflater();
		topText = (TextView) findViewById(R.id.topText);
		viewPager = (ViewPager) findViewById(R.id.viewpager);
		viewPager.setAdapter(new MyPagerAdapter(this,urlList));
		// viewPager.setCurrentItem(3);
		topText.setText("1/"+urlList.size());
		viewPager.setOnPageChangeListener(new OnPageChangeListener() {
			// 页面选择
			@Override
			public void onPageSelected(int position) {
				topText.setText("(" + String.valueOf(position + 1) + "/"
						+ String.valueOf(urlList.size()) + ")");
				Log.v("viewpager", "============" + position);
			}
			@Override
			public void onPageScrollStateChanged(int state) {
			}
			@Override
			public void onPageScrolled(int position,
			float positionOffset, int positionOffsetPixels) {

			}

		});
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		 MobclickAgent.onResume(this);
	}
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		 MobclickAgent.onPause(this);
	}
}